package com.linshengjian.power.entity;

import com.linshengjian.core.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import java.util.HashSet;
import java.util.Set;

@Accessors(chain = true)
@Data
@Entity(name = "permission")
public class PermissionEntity extends BaseEntity<Integer> {

    @Column(nullable = false, unique = true)
    private String code;
    @Column(nullable = false)
    private String name;
    private String description;

    @ManyToMany
    @Where(clause = "valid = true")
    private Set<ResourcesEntity> resources = new HashSet<>();
}
